<template>
    <div>
        <el-form :model="form" :rules="rules" ref="form">
            <el-form-item prop="name" label="系名" :label-width="formLabelWidth">
                <el-input v-model="form.name" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer" style="display: flex; justify-content: flex-end;">
            <el-button @click="cancel">取 消</el-button>
            <el-button type="primary" @click="submit">确 定</el-button>
        </div>

    </div>
</template>

<script>
import { departmentAdd } from '@/api/admin/department';
export default {
    data() {
        return {
            dialogFormVisible: false,
            form: {
                name: '',
                id: -1
            },
            formLabelWidth: '60px',
            rules: {
                name: [
                    { required: true, message: "请输入系名", trigger: 'blur' }
                ]
            }
        }
    },
    methods: {
        submit() {
            // console.log(this.form)
            this.$refs["form"].validate(f => {
                if (f) {
                    departmentAdd(this.form).then(res => {
                        console.log(res)
                        if (res.code === 0) {
                            this.$message({
                                type: "success",
                                message: res.data
                            })
                            this.$emit("close")
                        }
                    })
                }
            })
        },
        cancel() {
            this.$emit("cancelAdd")
        }
    }
}
</script>

<style lang="scss" scoped></style>